package com.leinao.media.enums;

/**
 * 大华错误码枚举类
 *
 * @author zhangyu
 * @date 2022/7/29 17:00
 */
public enum DhErrorEnum {

    NET_ERROR(-1, "未知错误"),

    NET_SYSTEM_ERROR(1, "Windows系统出错"),

    NET_NETWORK_ERROR(2, "网络错误"),

    NET_DEV_VER_NOMATCH(3, "设备协议不匹配"),

    NET_INVALID_HANDLE(4, "句柄无效"),

    NET_OPEN_CHANNEL_ERROR(5, "打开通道失败"),

    NET_CLOSE_CHANNEL_ERROR(6, "关闭通道失败"),

    NET_ILLEGAL_PARAM(7, "用户参数不合法"),

    NET_SDK_INIT_ERROR(8, "SDK初始化出错"),

    NET_SDK_UNINIT_ERROR(9, "SDK清理出错"),

    NET_RENDER_OPEN_ERROR(10, "申请render资源出错"),

    NET_DEC_OPEN_ERROR(11, "打开解码库出错"),

    NET_DEC_CLOSE_ERROR(12, "关闭解码库出错"),

    NET_MULTIPLAY_NOCHANNEL(13, "多画面预览中检测到通道数为0"),

    NET_TALK_INIT_ERROR(14, "录音库初始化失败"),

    NET_TALK_NOT_INIT(15, "录音库未经初始化"),

    NET_TALK_SENDDATA_ERROR(16, "发送音频数据出错"),

    NET_REAL_ALREADY_SAVING(17, "实时数据已经处于保存状态"),

    NET_NOT_SAVING(18, "未保存实时数据"),

    NET_OPEN_FILE_ERROR(19, "打开文件出错"),

    NET_PTZ_SET_TIMER_ERROR(20, "启动云台控制定时器失败"),

    NET_RETURN_DATA_ERROR(21, "对返回数据的校验出错"),

    NET_INSUFFICIENT_BUFFER(22, "没有足够的缓存"),

    NET_NOT_SUPPORTED(23, "当前SDK未支持该功能"),

    NET_NO_RECORD_FOUND(24, "查询不到录象"),

    NET_NOT_AUTHORIZED(25, "无操作权限"),

    NET_NOT_NOW(26, "暂时无法执行"),

    NET_NO_TALK_CHANNEL(27, "未发现对讲通道"),

    NET_NO_AUDIO(28, "未发现音频"),

    NET_NO_INIT(29, "网络SDK未经初始化"),

    NET_DOWNLOAD_END(30, "下载已结束"),

    NET_EMPTY_LIST(31, "查询结果为空"),

    NET_ERROR_GETCFG_SYSATTR(32, "获取系统属性配置失败"),

    NET_ERROR_GETCFG_SERIAL(33, "获取序列号失败"),

    NET_ERROR_GETCFG_GENERAL(34, "获取常规属性失败"),

    NET_ERROR_GETCFG_DSPCAP(35, "获取DSP能力描述失败"),

    NET_ERROR_GETCFG_NETCFG(36, "获取网络配置失败"),

    NET_ERROR_GETCFG_CHANNAME(37, "获取通道名称失败"),

    NET_ERROR_GETCFG_VIDEO(38, "获取视频属性失败"),

    NET_ERROR_GETCFG_RECORD(39, "获取录象配置失败"),

    NET_ERROR_GETCFG_PRONAME(40, "获取解码器协议名称失败");


    /**
     * 错误码
     */
    private int errorCode;

    /**
     * 提示信息
     */
    private String errorMsg;

    DhErrorEnum(int errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    /**
     * 根据错误码获取错误提示信息
     *
     * @param errorCode 错误码
     * @return 错误提示信息
     */
    public static String getErrorMsgByCode(int errorCode) {
        DhErrorEnum[] dhErrorEnums = values();
        for (DhErrorEnum dhErrorEnum : dhErrorEnums) {
            if (dhErrorEnum.getErrorCode() == errorCode) {
                return dhErrorEnum.getErrorMsg();
            }
        }
        return "";
    }

}
